import http from '@/utils/http'

const movie = {
  getAllTypes () {
    return http.get('/api/movies/categories')
  },

  getAllYear () {
    return http.get('/api/movies/years')
  },

  getMovieList (params) {
    console.log(params)

    let url = '/api/movies/movie-list' //获取影片列表的url
    let query = 'a=1' //定义一个无效常量参数，方便后续参数的动态拼接

    // for (key, value in params) {
    //   query += '&' + key + '=' + value
    // }
    url += '?' + query
    return http.get(url)
  },

  getMovies (keyword, pageNum, pageSize) {
    return http.get('/api/movies/movie-list', {
      pageNum,
      pageSize,
      keyword
    })
  },

  getMovieDetail (id) {
    return http.get('/api/movies/detail/' + id)
  },

  getMovieActors (id) {
    return http.get('/api/movies/actors/' + id)
  },

  getMovieRatings (id) {
    return http.get('/api/movies/ratings/' + id)
  },
  deleteMovie (id) {
    return http.delete('/api/movies/admin/delete/' + id)
  }
}

export default movie
